08. Custom SKLearn Model

Defining a Custom Model

To define a custom model, you need to have the model itself and the following two scripts:

  • A training script that defines how the model will accept input data, and train. This script should also save the trained model parameters.
  • A predict script that defines how a trained model produces an output and in what format.

PyTorch

In PyTorch, you have the option of defining a neural network of your own design. These models do not come with any built-in predict scripts and so you have to write one yourself.

SKLearn

The scikit-learn library, on the other hand, has many pre-defined models that come with train and predict functions attached!

You can define custom SKLearn models in a very similar way that you do PyTorch models only you typically only have to define the training script. You can use the default predict function.